package com.ahq.main;

import com.dalonedrau.jogl.engine.Engine;
import com.dalonedrau.jogl.engine.GameApplet;
import com.dalonedrau.jogl.engine.GameController;
import com.dalonedrau.jogl.engine.GameState;
import com.dalonedrau.jogl.engine.JOGLErrorHandler;
import com.dalonedrau.jogl.opengl.FontProperties;
import com.dalonedrau.jogl.util.UtilityMethods;
import com.module.bp.bus.BPConstants;
import com.module.bp.engine.BPController;
import com.module.hq.engine.HQConstants;
import com.module.hq.engine.HQController;
import com.module.hq.engine.HQInteractive;
import com.module.osr.engine.OSRConstants;
import com.module.osr.engine.OSRController;


/**
 * Applet entry point.
 * @author Donald
 */
public final class AHQApplet extends GameApplet {
	/** serial id. */
	private static final long	serialVersionUID	= 1L;
	/** <code>LogItem</code> object. */
	// private static final Log LOGGER = LogFactory.getLog(AresApplet.class);
	/*
	 * (non-Javadoc)
	 * @see java.applet.Applet#init()
	 */
	@Override
	public void init() {
		try {
			GameApplet.setInstance(this);
			this.setFocusable(true);
			FontProperties.getInstance().initFontProperties(
			"lovecraft_24.properties");
			FontProperties.getInstance().initFontProperties(
			"thalia_24.properties");
			FontProperties.getInstance().initFontProperties(
			"quentin_20.properties");
			FontProperties.getInstance().initFontProperties(
			"stormbringer_21.properties");
			//new BPConstants();
			//new OSRConstants();
			new HQConstants();
			// System.setProperty("sun.java2d.noddraw", "true");
			// System.setProperty("sun.awt.noerasebackground", "true");
			// ADD SPLASH PAGE
			/*
			 * FontFactory.loadTrueTypeFont(
			 * Controller.getInstance().getGlobalString("FONT_DEFAULT"));
			 */
			// FontFactory.loadTrueTypeFont(Globals.FONT_DEFAULT);
			// Init.initGameData();
			// InitUI.init("ui.properties");
			// Controller.ANIMATOR.start();
			// Controller.switchScreen();
			// 60 frames per second
			final long fps = 60L;
			// engine should loop at 1 second / # of frames
			// so for 60 fps, the loop should take 16ms
			new Engine(UtilityMethods.getInstance().convertMilliToNano(
					1000L / fps));
			//OSRController.getInstance();
		} catch (Exception ex) {
			JOGLErrorHandler.getInstance().fatalError(ex);
		}
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void start() {
		// starts the actual applet
		try {
			GameState.getInstance().nextState();
		} catch (Exception ex) {
			AHQApplet.getInstance().fatalError(ex);
		}
	}
}